package cn.ito.zjgsu.utils.impl.excel;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;

import org.apache.poi.util.IOUtils;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.exception.excel.ExcelImportException;


public class WrapperUtil {

	public static <T> List<T> warpedImportExcel(File file, Class<?> pojoClass, ImportParams params) {
		FileInputStream in = null;
		try {
			in = new FileInputStream(file);
			return new ExcelImportServerWrapper().importExcelByIs(in, pojoClass, params).getList();
		} catch (ExcelImportException e) {
			throw new ExcelImportException(e.getType(), e);
		} catch (Exception e) {
			throw new ExcelImportException(e.getMessage(), e);
		} finally {
			IOUtils.closeQuietly(in);
		}
	}

}
